<?php

/**
 * This is the model class for table "{{contenter}}".
 *
 * The followings are the available columns in table '{{contenter}}':
 * @property integer $c_id
 * @property string $c_name
 * @property string $c_value
 * @property integer $c_createtime
 * @property integer $c_updatetime
 * @property integer $c_isdel
 */
class Contenter extends CActiveRecord
{
	private $keylimits = array(
	'contactus',
	'aboutus',
	'aq',
	'groupintro',
	'groupqua',
	'hitewellintro',
	'servicecenter',
	'dianli',
	'shihua',
	'shuichuli',
	'lianyou',
	'gangtie',
	'zaozhi',
	'hedian',
	'qita',
	'chanpindongtai',
	'chanpindongtaiA',
	'chanpindongtaiB',
	'gongsidongtai',
	'gongsidongtaiA',
	'gongsidongtaiB',
	);
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{contenter}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function ifexsit($key)
	{
		if(in_array($key,$this->keylimits))return true;
		else {throw new CHttpException(404,'您访问的页面不存在。');return false;exit;}
	}
	
	
	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('c_name, c_createtime, c_updatetime', 'required'),
			array('c_createtime, c_updatetime, c_isdel', 'numerical', 'integerOnly'=>true),
			array('c_name', 'length', 'max'=>100),
			array('c_value', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('c_id, c_name, c_value, c_createtime, c_updatetime, c_isdel', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'c_id' => 'C',
			'c_name' => 'C Name',
			'c_value' => 'C Value',
			'c_createtime' => 'C Createtime',
			'c_updatetime' => 'C Updatetime',
			'c_isdel' => 'C Isdel',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('c_id',$this->c_id);
		$criteria->compare('c_name',$this->c_name,true);
		$criteria->compare('c_value',$this->c_value,true);
		$criteria->compare('c_createtime',$this->c_createtime);
		$criteria->compare('c_updatetime',$this->c_updatetime);
		$criteria->compare('c_isdel',$this->c_isdel);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Contenter the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
